import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        long c = scanner.nextLong();

        HashMap<Long, Long> map = new HashMap<>();

        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextLong();
            map.put(arr[i], map.getOrDefault(arr[i], 0l) + 1);
        }

        long ret = 0;
        for (Map.Entry<Long, Long> entry : map.entrySet()) {
            long num = map.getOrDefault(entry.getKey() - c, 0l);
            ret += num * entry.getValue();
        }

        System.out.println(ret);

        scanner.close();
    }
}
